package util.components.buttons;

import java.awt.Color;

import javax.swing.Icon;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

import patterns.Command;

import util.Constantes;
import view.JanelaPrincipal;

public class JToogleButtonMenu extends javax.swing.JToggleButton implements Command{

	private JanelaPrincipal janela;
	private int menu_index;
	private TitledBorder borda;

	public JToogleButtonMenu(JanelaPrincipal j, int menu, Icon icon) {
		super(icon);

		this.menu_index = menu;
		this.janela = j;
		this.borda = new TitledBorder (new LineBorder (Color.GRAY, 2,true),"",TitledBorder.CENTER,TitledBorder.TOP);
	}

	public void execute() {
		trocaMenu(menu_index);
	}

	private void trocaMenu(int indice) {
		janela.getPanelBotao().setPanelBotao(indice);
		janela.trocarMenu();
		borda.setTitle(Constantes.MENU[indice]);
		janela.getPanelBotao().setBorder(borda);
	}
}
